package interview.threads;

public class ThreadLocalDemo {

    public static void main(String[] args) {


        ThreadLocal threadLocal  = new ThreadLocal(){
            @Override
            protected Long initialValue() {
                System.out.println("innit value...");
                return Thread.currentThread().getId();
            }
        };

        new Thread(new Runnable() {
            @Override
            public void run() {
                threadLocal.set(20l);
                System.out.println(Thread.currentThread().getName()+"****"+threadLocal.get());
            }
        }).start();
        new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println(Thread.currentThread().getName()+"****"+threadLocal.get());
            }
        }).start();
        new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println(Thread.currentThread().getName()+"****"+threadLocal.get());
            }
        }).start();






        System.out.println(threadLocal.get());
    }
}
